import { AccountListGetResultModel } from '@/api/demo/model/systemModel';

import { defHttp } from '@/utils/http/axios';
import { BasicFetchResult } from '@/api/model/baseModel';

enum Api {
  Task = '/task',
  List = '/task/list',
}

export interface TaskVO {
  id: number;
  name: string;
  url: string;
  url2: string;
  period: number;
  request_frequency: number;
  format: string;
  comment: string;
}

export const task_post = (vo: TaskVO) =>
  defHttp.post<AccountListGetResultModel>({ url: Api.Task, data: vo });

export const task_get = (id: number) => defHttp.get<TaskVO>({ url: Api.Task + '?id=' + id });

export const task_put = (vo: TaskVO) =>
  defHttp.put<AccountListGetResultModel>({ url: Api.Task + '?id=' + vo.id, data: vo });

export const task_delete = (id: number) =>
  defHttp.delete<AccountListGetResultModel>({ url: Api.Task + '?id=' + id });

export const task_list = (params: any) =>
  defHttp.get<BasicFetchResult<TaskVO>>({ url: Api.Task, params });
